package controllers;

/**
 * @author agurgul
 * Class containing 4 cards on player's hand and two fields of money left i.e. cash on hand and value of a bid
 * that is already in.
 * @DONE 	Dodac konstruktor. IMHO trzeba przemyslec czy takowemu potrzebne jest cialo. Na pewno nie moze
 * przyznawac kart ani bida. Co do balance tez trzeba sie zastanowic
 * @TODO	Sortowanie kart na reku, na biezaco.
 */
public class Player {
	/**
	 * An array to storage player's 4 cards.
	 */
	private final Card[] cards = new Card[4];
	/**
	 * Player's current account balance
	 */
	private int balance;

	/**
	 * The ID of the player.
	 */
	private int id;

	public int getID() {
		return id;
	}

	/**
	 * Player's currently on-table balance.
	 */
	private int bid = 0;
	/**
	 * Player's cards to change. Each true means a certain card to change.
	 */
	private final boolean[] slotsToChange = new boolean[4];

	/**
	 * Indicates, whether the player has played all-in.
	 */
	private boolean allIn;

	public boolean isAllIn() {
		return allIn;
	}

	public void setAllIn( boolean allIn ) {
		this.allIn = allIn;
	}

	/**
	 *  Indicate, whether the player has folded in this game.
	 */
	private boolean folded = false;

	public boolean isFolded() {
		return folded;
	}

	public void setFolded( boolean folded ) {
		this.folded = folded;
	}

	/**
	 * Indicates, whether the player has already lost in this game.
	 */
	private boolean lost = false;

	public void setLost( boolean lost ) {
		this.lost = lost;
	}

	public boolean isLost() {
		return lost;
	}

	/**
	 * Public method returning slotsToChange
	 * @return boolean[]
	 */
	public boolean[] getSlotsToChange(){
		return slotsToChange;
	}
	/**
	 * @param i Index of a card + 1, so the 1st card is the 0th in the array
	 * @return Card
	 */
	public Card getCard(int i){
		return cards[i-1];
	}
	/**
	 * @return int
	 */
	public int getBalance() {
		return balance;
	}
	/**
	 * @return int
	 */
	public int getBid() {
		return bid;
	}	
	/**
	 * @return Card[]
	 */
	public Card[] getCards(){
		return cards;
	}
	/**
	 * @param balance new balance to be set
	 */
	public void setBalance(int balance) {
		this.balance = balance;
	}
	/**
	 * @param bid new bid to be set
	 */
	public void setBid(int bid) {
		this.bid = bid;
	}
	/**
	 * @param card Card to be set
	 * @param i slot to be set
	 */
	public void setCard(Card card, int i){
		this.cards[ i ] = card;
	}
	/**
	 * @param bool value to be set on a slot
	 * @param slot slot on which value would be set
	 */
	public void setSlotToChange(boolean bool, int slot){
		this.slotsToChange[slot] = bool;
	}

	/**
	 * Public constructor 
	 */
	public Player( int id ) {
		this.id = id;
	}
}
